<template>
  <view class="book-success" :style="'padding-top:' + navHeight + 'px;'">
    <view class="success-info">
      <image class="success-logo" :src="successLogo"></image>
      <span v-if="!isFailed">预约成功</span>
      <span v-if="isFailed">预约失败</span>
      <image
        class="yljob-logo"
        :src="ylJobCode"
        @click.self="previewImage"
        show-menu-by-longpress="true"
      ></image>
      <view class="remind-info">
        <view>长按识别二维码关注一览职业公众号</view>
        <view>能更快提醒你咨询顾问的时间到了~</view>
      </view>
    </view>
    <view class="button-list">
      <view v-if="!isFailed" class="background-orange" @click="jumpToWXPublic"
        >开启顾问咨询服务时间提醒</view
      >
      <view
        v-if="isFailed"
        class="background-orange"
        @click="bookConsultantAgain"
        >重新去预约顾问</view
      >
      <view v-if="!isFailed" class="background-white" @click="gotoBookDetail"
        >查看预约信息</view
      >
      <view class="background-white" @click="gotoIndex">回到职途主页</view>
    </view>
  </view>
</template>

<script>
import { consultantInfo } from "@/api/modules/career";
import { addAppointment } from "@/api/index";

export default {
  components: {},
  data() {
    return {
      navHeight: getApp().globalData.navHeight,
      successLogo: this.$imgBase + "careerPath/bookSuccess.png",
      ylJobCode: this.$imgBase + "careerPath/ylJobCode.png",
      isFailed: false,
    };
  },
  onLoad(opt) {
    if (opt.isFailed) {
      this.isFailed = opt.isFailed;
      this.successLogo = this.$imgBase + "careerPath/bookFailed.png";
    }
  },
  onShow() {},
  onHide() {},
  mounted() {},
  // 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
  onReady() {},
  methods: {
    gotoBookDetail() {
      uni.navigateTo({
        url: "/pagesSub/userCenter/careerPathV2/components/BookInfoConfirm?isCheck=ture&&cancelavailable=true&&&&isOverdue=false",
      });
    },
    gotoIndex() {
      uni.redirectTo({
        url: "/pagesSub/userCenter/careerPathV2/index",
      });
    },
    jumpToWXPublic() {
      // let ids = "TRlf5BwDO5qFRCR3F-5Kolks2NT3OQBbZvEhzGvM1VQ";
      uni.requestSubscribeMessage({
        tmplIds: [
          "-VgyrhPMJG8b_ZknZaBzNdTd5RqMQESZlZo3sMiiSFc",
          "z_G2uub-vdlGvYrJl6w8ZJX5LLYJBYtVYhEHIAVpodo",
        ],
        complete: (res) => {
          console.log("requestSubscribeMessage complete", res);
          //console.log('requestSubscribeMessage ids',res[''+ ids +'']);
          // var value = res["" + ids + ""];
          // if (value == "accept") {
          //   console.log("requestSubscribeMessage value", "accept");
          //   // 接受了
          // } else if (value == "reject") {
          //   console.log("requestSubscribeMessage value", "reject");
          //   // 拒绝了
          // }
        },
      });
    },
    bookConsultantAgain() {
      uni.navigateTo({
        url: "/pagesSub/userCenter/careerPathV2/components/BookConsultant",
      });
    },
    previewImage() {
      uni.previewImage({
        // 需要预览的图片链接列表。若无需预览，可以注释urls
        urls: [e.target.src],
        // 为当前显示图片的链接/索引值
        current: e.target.src,
        // 图片指示器样式
        indicator: "default",
        // 是否可循环预览
        loop: false,
        // 长按图片显示操作菜单，如不填默认为保存相册
        longPressActions: {
          itemList: [this.l("发送给朋友"), this.l],
        },
        success: (res) => {
          console.log("previewImage res", res);
        },
        fail: (err) => {
          console.log("previewImage err", err);
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
$img-base-person: $img-base + "careerPath/";
.book-success {
  width: 100%;
  background-color: #ffffff;
  padding: 100rpx 16rpx;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  .success-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    .success-logo {
      width: 146rpx;
      height: 146rpx;
    }
    .yljob-logo {
      margin-top: 60rpx;
      width: 234rpx;
      height: 234rpx;
    }
    span {
      width: 169rpx;
      height: 40rpx;
      font-size: 40rpx;
      font-family: PingFang-SC, PingFang-SC;
      font-weight: bold;
      color: #222222;
      line-height: 40rpx;
      margin-top: 64rpx;
    }
    .remind-info {
      margin-top: 60rpx;
      view {
        width: 552rpx;
        /* height: 80rpx; */
        font-size: 28rpx;
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        color: #333333;
        line-height: 40rpx;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        margin-bottom: 10rpx;
      }
    }
  }
  .button-list {
    view {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      border-radius: 16rpx;
      height: 80rpx;
      font-size: 28rpx;
      font-family: PingFangSC, PingFang SC;
      font-weight: 500;
      margin-bottom: 32rpx;
    }
    .background-orange {
      background: #f75a3e;
      color: #ffffff;
    }
    .background-white {
      background: #ffffff;
      color: #f75a3e;
      border: 2rpx solid #f75a3e;
    }
  }
}
</style>
